Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to ensure across() allows tidyselect renaming #6953

Merged

Conversation

DavisVaughan
Copy link
Member

Closes #6895

@hadley I think this is a valid usage of across() + renaming-in-tidyselect, do you agree?

library(dplyr, warn.conflicts = FALSE)
library(rlang)

df <- tibble::tibble(a = 1, b = 2, c = 3)

cols <- set_names(c("a", "b"), c("x", "y"))

df %>%
  mutate(
    across(
      .cols = all_of(cols),
      .fns = ~ .x + 10
    )
  )
#> # A tibble: 1 × 5
#>       a     b     c     x     y
#>   <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1     1     2     3    11    12

Extracted from #6895 (comment), adding a test because I didn't see any and want to ensure this continues to work.

@DavisVaughan DavisVaughan merged commit faacd32 into tidyverse:main Nov 6, 2023
11 checks passed
@DavisVaughan DavisVaughan deleted the feature/test-renaming-in-cols branch November 6, 2023 13:51
@hadley
Copy link
Member

hadley commented Nov 6, 2023

Yeah, seems fine to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confirm if dplyr::across can pass same length of vector to .names
2 participants